package com.dashuai.modbus.config;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author QM
 * @date 2024/8/22
 */
@ConfigurationProperties(prefix = TCPSlaveProperties.MODBUS_TCP_SLAVE_PREFIX)
//@EnableConfigurationProperties(ProcessImageProperties.class)
public class TCPSlaveProperties {


    public static final String MODBUS_TCP_SLAVE_PREFIX = "modbus.tcp.slave";

    private int port = 502;

    private boolean encapsulated = false;

//    @NestedConfigurationProperty
    private List<ProcessImageProperties> processImages;


    public TCPSlaveProperties() {
    }


    public TCPSlaveProperties(int port, boolean encapsulated, List<ProcessImageProperties> processImages) {
        this.port = port;
        this.encapsulated = encapsulated;
        this.processImages = processImages;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public boolean getEncapsulated() {
        return encapsulated;
    }

    public void setEncapsulated(boolean encapsulated) {
        this.encapsulated = encapsulated;
    }

    public List<ProcessImageProperties> getProcessImages() {
        return processImages;
    }

    public void setProcessImages(List<ProcessImageProperties> processImages) {
        this.processImages = processImages;
    }


    @Override
    public String toString() {
        return "ModbusTCPSlaveProperties{" +
                "port=" + port +
                ", encapsulated=" + encapsulated +
                ", processImages=" + processImages +
                '}';
    }
}
